#include "NeoFluent.h"
#include <QApplication>
#include <QLayout>
#include <QTimer>

int main(int argc, char *argv[])
{
  QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
  QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  QApplication app(argc, argv);
  QFont font = app.font();
  font.setPixelSize(13);
  font.setFamily("Microsoft YaHei");
  font.setHintingPreference(QFont::PreferNoHinting);
  app.setFont(font);

  QWidget window;
  QTabWidget tabWidget(&window);
  tabWidget.setTabPosition(QTabWidget::North);

  QWidget *baseComponents = new QWidget(&tabWidget);
  QGridLayout *baseLayout = new QGridLayout(baseComponents);

  NeoPushButton *pushButton = new NeoPushButton(baseComponents);
  pushButton->setIcon(NeoIconInstance->getNeoIcon(NeoIconType::FontAwesomeSolid::AddressBook, Qt::blue, 64, 64, 64));
  pushButton->setIconSize(QSize(64, 64));
  pushButton->setButtonStyle(NeoPushButtonType::ButtonIconOnly);
  pushButton->setFixedSize(170, 80);
  baseLayout->addWidget(pushButton, 0, 0);

  NeoSwitchButton *switchButton = new NeoSwitchButton(baseComponents);
  switchButton->setFixedSize(60, 30);
  baseLayout->addWidget(switchButton, 0, 1);

  NeoToggleButton *toggleButton = new NeoToggleButton(baseComponents);
  toggleButton->setText("Toggle");
  toggleButton->setIcon(NeoIconType::FontAwesomeSolid::Check);
  toggleButton->setFixedSize(120, 40);
  baseLayout->addWidget(toggleButton, 0, 2);

  NeoComboBox *comboBox = new NeoComboBox(baseComponents);
  comboBox->setFixedSize(150, 35);
  comboBox->addItem("Item 1");
  comboBox->addItem("Item 2");
  comboBox->addItem("Item 3");
  comboBox->addItem("Item 4");
  comboBox->addItem("Item 5");
  comboBox->addItem("Item 6");
  comboBox->addItem("Item 7");
  baseLayout->addWidget(comboBox, 1, 0);

  NeoSpinBox *spinBox = new NeoSpinBox(baseComponents);
  spinBox->setFixedSize(120, 30);
  baseLayout->addWidget(spinBox, 2, 0);

  NeoDoubleSpinBox *doubleSpinBox = new NeoDoubleSpinBox(baseComponents);
  doubleSpinBox->setFixedSize(130, 30);
  baseLayout->addWidget(doubleSpinBox, 2, 1);

  NeoLineEdit *lineEdit = new NeoLineEdit(baseComponents);
  lineEdit->setFixedSize(150, 30);
  lineEdit->addAction(NeoIconInstance->getNeoIcon(NeoIconType::FontAwesomeSolid::Eye, Qt::black, 15, 20, 20), NeoLineEdit::TrailingPosition);
  baseLayout->addWidget(lineEdit, 3, 0);

  NeoSlider *slider = new NeoSlider(baseComponents);
  slider->setFixedSize(300, 20);
  baseLayout->addWidget(slider, 4, 0);

  NeoProgressBar *progressBar = new NeoProgressBar(baseComponents);
  progressBar->setFixedSize(300, 30);
  progressBar->setBackgroundColor(Qt::lightGray);
  progressBar->setProgressColor(Qt::green);
  progressBar->setMinimumValue(0);
  progressBar->setMaximumValue(100);
  baseLayout->addWidget(progressBar, 4, 1);

  NeoProgressCircle *progressCircle = new NeoProgressCircle(baseComponents);
  progressCircle->setFixedSize(100, 100);
  progressCircle->setBackgroundColor(Qt::lightGray);
  progressCircle->setProgressColor(Qt::blue);
  progressCircle->setMinimumValue(0);
  progressCircle->setMaximumValue(100);
  baseLayout->addWidget(progressCircle, 4, 2);

  tabWidget.addTab(baseComponents, "Base Components");

  QWidget *extentComponents = new QWidget(&tabWidget);
  QGridLayout *extentLayout = new QGridLayout(extentComponents);

  NeoLoadCircle *loadCircle = new NeoLoadCircle(extentComponents);
  loadCircle->setFixedSize(100, 100);
  extentLayout->addWidget(loadCircle, 0, 0);

  NeoBiCalibro *biCalibro = new NeoBiCalibro(baseComponents);
  biCalibro->setFixedSize(200, 200);
  extentLayout->addWidget(biCalibro, 1, 0);

  NeoRoller *roller = new NeoRoller(extentComponents);
  roller->setFixedSize(80, 200);
  QStringList items;
  for (int i = 0; i < 100; ++i)
  {
    items.append(QString::number(i));
  }
  roller->setItems(items);
  roller->setMaxVisibleItems(5);
  extentLayout->addWidget(roller, 1, 1);

  NeoCalendar *calendar = new NeoCalendar(extentComponents);
  calendar->setFixedSize(400, 480);
  extentLayout->addWidget(calendar, 2, 0);

  tabWidget.addTab(extentComponents, "Extended Components");

  QTimer::singleShot(3000, [&]()
                     {
                       progressBar->setValue(50);
                        progressCircle->setValue(100);
                        loadCircle->start(); });

  QHBoxLayout *layout = new QHBoxLayout(&window);
  layout->addWidget(&tabWidget);
  window.show();

  return app.exec();
}